var searchInsert = function (nums, target) {
  // for(var i in nums) {
  //   if(nums[i]>=target) return i
  // }
  // return nums.length
  let left = 0
  let right = nums.length-1
  let ans = 0
  while(left<=right) {
    let mid = Math.floor((left+right)/2)
    if(target<=nums[mid]) {
      ans = mid 
      right = mid - 1
    }else {
      left = mid+1
    }
  }
  return ans
};
let nums = [1,3,5,6], target = 5
// console.log(searchInsert(nums,target));
let right = 0,left = 5
let mid = ((right - left) >> 1) + left
console.log(mid);